import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Form';
import { h } from 'vue';

const renderFun = (data: any, ischeck = false) => {
  const span = h(
    'span',
    {
      style: {
        color: 'rgb(255,84,0)',
      },
      title: data.value,
    },
    ischeck ? '是' : data.value,
  );

  return data.record.status === null ? (ischeck ? '否' : data.value) : span;
};

// 已编箱列表 及 搜索区域
export const leftColumn: BasicColumn[] = [
  {
    dataIndex: 'boxCode',
    title: '编箱号',
  },
  {
    dataIndex: 'boxNumbers',
    title: '数量',
    width: 60,
  },
  // {
  //   dataIndex: 'createTime',
  //   title: '创建时间',
  // },
  {
    dataIndex: 'createBy',
    title: '操作员',
  },
];

export const leftSearchSchemas: FormSchema[] = [
  {
    field: 'boxCode',
    label: '箱号',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
  {
    field: 'createBy',
    label: '操作员',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
];

// 已编箱水表
export const rightSchemsColumn1: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
  },
  {
    dataIndex: 'operator',
    title: '操作员',
    width: 140,
  },
  {
    dataIndex: 'boxCode',
    title: '箱号',
    width: 140,
  },
  {
    dataIndex: 'waterMeterType',
    title: '型号',
    width: 140,
  },
  {
    dataIndex: 'caliber',
    title: '口径',
    width: 140,
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
    width: 140,
  },
  {
    dataIndex: 'result',
    title: '检定结果',
    width: 140,
  },
  {
    dataIndex: 'checkDate',
    title: '检定日期',
    width: 140,
  },

  {
    dataIndex: 'q1',
    title: 'Q₁',
    width: 140,
  },
  {
    dataIndex: 'q2',
    title: 'Q₂',
    width: 140,
  },
  {
    dataIndex: 'q3',
    title: 'Q₃',
    width: 140,
  },
];

export const rightSearchSchems1: FormSchema[] = [
  {
    field: 'waterMeterCode',
    label: '表码',
    component: 'Input',
    labelWidth: 60,
    colProps: {
      span: 6,
    },
  },

  {
    field: 'boxCode',
    label: '箱号',
    labelWidth: 60,
    component: 'Input',
    colProps: {
      span: 6,
    },
  },
  {
    field: 'operator',
    label: '操作员',
    labelWidth: 60,
    component: 'Input',
    colProps: {
      span: 6,
    },
  },
];

// 合格未编箱
export const rightSchemsColumn2: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
  },
  {
    dataIndex: 'operator',
    title: '操作员',
    width: 140,
  },
  {
    dataIndex: 'deviceNumber',
    title: '装置编号',
    width: 140,
  },
  {
    dataIndex: 'waterMeterType',
    title: '型号',
    width: 140,
  },
  {
    dataIndex: 'caliber',
    title: '口径',
    width: 140,
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
    width: 140,
  },
  {
    dataIndex: 'result',
    title: '检定结果',
    width: 140,
  },
  {
    dataIndex: 'checkDate',
    title: '检定日期',
    width: 140,
  },

  {
    dataIndex: 'q1',
    title: 'Q₁',
    width: 140,
  },
  {
    dataIndex: 'q2',
    title: 'Q₂',
    width: 140,
  },
  {
    dataIndex: 'q3',
    title: 'Q₃',
    width: 140,
  },
];

export const rightSearchSchems2: FormSchema[] = [
  {
    field: 'waterMeterCode',
    label: '表码',
    component: 'Input',

    colProps: {
      span: 8,
    },
  },
];

// 不合格水表
export const rightSchemsColumn3: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'operator',
    title: '操作员',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'waterMeterType',
    title: '型号',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'caliber',
    title: '口径',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'result',
    title: '检定结果',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'status',
    title: '是否复检',
    width: 140,
    customRender: (data) => renderFun(data, true),
  },
  {
    dataIndex: 'checkDate',
    title: '检定日期',
    width: 140,
    customRender: (data) => renderFun(data),
  },

  {
    dataIndex: 'q1',
    title: 'Q₁',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'q2',
    title: 'Q₂',
    width: 140,
    customRender: (data) => renderFun(data),
  },
  {
    dataIndex: 'q3',
    title: 'Q₃',
    width: 140,
    customRender: (data) => renderFun(data),
  },
];

export const rightSearchSchems3: FormSchema[] = [
  {
    field: 'waterMeterCode',
    label: '表码',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
];

// // 待检定水表
export const rightSchemsColumn4 = (waterStatusArr) => [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
  },
  {
    dataIndex: 'waterMeterType',
    title: '型号',
    width: 140,
  },
  {
    dataIndex: 'caliber',
    title: '口径',
    width: 140,
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
    width: 140,
  },

  {
    dataIndex: 'waterMeterStatus',
    title: '检测状态',
    width: 140,
    customRender: ({ record }) => {
      let str = '-';
      const obj = waterStatusArr.find((i) => i.value === record.waterMeterStatus);
      if (obj) {
        str = obj.label;
      }
      return str;
    },
  },
];

export const rightSearchSchems4: FormSchema[] = [
  {
    field: 'waterMeterCode',
    label: '表码',
    component: 'Input',

    colProps: {
      span: 8,
    },
  },
];

// 复检水表
export const rightSchemsColumn5: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
  },
  {
    dataIndex: 'operator',
    title: '操作员',
    width: 140,
  },
  {
    dataIndex: 'waterMeterType',
    title: '型号',
    width: 140,
  },
  {
    dataIndex: 'caliber',
    title: '口径',
    width: 140,
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
    width: 140,
  },
  {
    dataIndex: 'result',
    title: '检定结果',
    width: 140,
  },
  {
    dataIndex: 'checkDate',
    title: '检定日期',
    width: 140,
  },

  {
    dataIndex: 'q1',
    title: 'Q₁',
    width: 140,
  },
  {
    dataIndex: 'q2',
    title: 'Q₂',
    width: 140,
  },
  {
    dataIndex: 'q3',
    title: 'Q₃',
    width: 140,
  },
];

export const rightSearchSchems5: FormSchema[] = [
  {
    field: 'waterMeterCode',
    label: '表码',
    component: 'Input',

    colProps: {
      span: 8,
    },
  },
];

export const QrBoxSchemas: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
  },
  {
    dataIndex: 'certificateCode',
    title: '合格证编码',
  },
];

export const QSchemas: BasicColumn[] = [
  {
    dataIndex: 'waterMeterCode',
    title: '表码',
    width: 140,
  },
  {
    dataIndex: 'checkDate',
    title: '检定日期',
    width: 140,
  },
  {
    dataIndex: 'number',
    title: '强检序号',
  },
  {
    dataIndex: 'firm',
    title: '送检单位',
    width: 300,
  },
  {
    dataIndex: 'factory',
    title: '生产厂家',
  },
  {
    dataIndex: 'instrumentName',
    title: '计量器具名称',
  },
  {
    dataIndex: 'waterCodeType',
    title: '表类型',
  },
  {
    dataIndex: 'typeSpec',
    title: '型号规格',
  },
  {
    dataIndex: 'caliberDn',
    title: '口径',
  },
  {
    dataIndex: 'verifyingBasic',
    title: '检定依据',
  },
  {
    dataIndex: 'standardDevice',
    title: '标准装置',
  },
  {
    dataIndex: 'verifyingParam',
    title: '检定参数',
  },
  {
    dataIndex: 'indoorTemperature',
    title: '环境温度',
  },
  {
    dataIndex: 'validUntil',
    title: '有效期至',
  },
  {
    dataIndex: 'transformTest',
    title: '电子装置功能判定',
  },
  {
    dataIndex: 'pressureTest',
    title: '密封性',
  },
  {
    dataIndex: 'indicationErrorResult',
    title: '示值误差判定',
  },
  {
    dataIndex: 'result',
    title: '检定结果',
  },
  {
    dataIndex: 'deviceNumber',
    title: '装置编号',
  },
  {
    dataIndex: 'accuracyClass',
    title: '准确度等级',
  },
  {
    dataIndex: 'pipeTemperature',
    title: '水温',
  },
  {
    dataIndex: 'pipePressure',
    title: '水压',
  },
  {
    dataIndex: 'pulseEquivalent',
    title: '脉冲当量',
  },
  {
    dataIndex: 'density',
    title: '密度',
  },
  {
    dataIndex: 'indicationError',
    title: '示值误差',
  },
  {
    dataIndex: 'eleMechanialError',
    title: '机电转换误差',
  },

  {
    dataIndex: 'q1',
    title: 'Q₁',
  },
  {
    dataIndex: 'q2',
    title: 'Q₂',
  },
  {
    dataIndex: 'q3',
    title: 'Q₃',
  },
  {
    dataIndex: 'q4',
    title: 'Q₄',
  },

  {
    title: 'Q₂/Q₁',
    dataIndex: 'q2q1',
  },
  {
    title: 'Q₄/Q₃',
    dataIndex: 'q4q3',
  },
  {
    title: 'Q₃/Q₁',
    dataIndex: 'q3q1',
  },
  {
    title: '最大流量',
    dataIndex: 'maxFlow',
  },
  {
    title: '最小流量',
    dataIndex: 'minFlow',
  },
  {
    title: '常用流量',
    dataIndex: 'commonFlow',
  },
  {
    title: '机电转换误差限',
    dataIndex: 'eleMechanialErrorLimit',
  },
  {
    title: '复检',
    dataIndex: 'recheck',
  },
  {
    title: '外观、标志和封印',
    dataIndex: 'visualInspection',
  },
  {
    title: '数据描述',
    dataIndex: 'dataSrc',
  },
];

// 复检水表详情表头
export const recheckSchemas: BasicColumn[] = [
  {
    title: '表码',
    dataIndex: 'waterMeterCode',
    width: 140,
  },
  {
    dataIndex: 'typeSpec',
    title: '型号规格',
    width: 140,
  },
  {
    dataIndex: 'caliberDn',
    title: '口径',
    width: 140,
  },
];
